﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace XBD.MyBaseCode
{
    internal class instance
    {

        //partial 局部类
        public partial class Point 
        {
            //第九维度

            public int Delta { get; set; }

            public void PrintDelta() 
            {
                Console.WriteLine("我是第九维度");
            }
        }
        public  partial class Point
        {
            //成员变量X轴，使用属性
            private int _x;
            public int X
            {
                get { return this._x; }
                set
                {
                    if (value < 0)
                    {
                        throw new Exception("Value 不能小于0");
                    }
                    this._x = value;
                }
            }
            //成员变量X轴，使用属性
            private int y;

            public int Y
            {
                get { return this.y; }
                set
                {
                    if (value < 0)
                    {
                        throw new Exception("Value 不能小于0");
                    }
                    this.y = value;
                }
            }
            //成员变量Z轴，自动生成getter 和setter
            public int Z { get; set; }

            //时间维度  readonly 只读
            public int T { get; } = 5;

            //第五维度 ,奇点 sigularity ,只写操作

            private int _s;
            public int S { set { _s = value; } }

            //第六维度 常量
            const int a = 99;
            //第七维度 readonly 

            public readonly int b;

            //第八维数据,索引
            public string[] gamma = new string[]
            {
                  "The",          //0   ^4
                  "Quick",        //1   ^3
                  "Cat",          //2   ^2
                  "Dog"           //3   ^1
            };

            public string this[int index]
            {
                get
                {
                    return gamma[index];
                }
                set
                {
                    gamma[index] = value;
                }
            }

            //索引的重载
            public int this[string str]
            {
                get
                {
                    return Array.IndexOf(gamma,str);
                }
            }

            //构造方法的重载
            public Point()
            {
                this._x = 1;
                this.y = 1;
                b = 1000;
                //this.T = 2;
            }
            //构造方法的重载，通过定义不同参数
            public Point(int x, int y)
            {
                this._x = x;
                this.y = y;
                b = 999;
            }

            public void DrawPoint(Point point) =>
            Console.WriteLine($"左边点为 x:{point._x},b:{point.y}");

            public double GetDistances(Point p) =>
             Math.Pow(_x - p._x, 2) + Math.Pow(y - p.y, 2);
        }

        // public static void DrPoint(dynamic Point)=>
        //Console.WriteLine($"左边点为 a:{Point.wether},b:{Point.temperature}");

        /*public static void DrawPoint(Point point) =>
            Console.WriteLine($"左边点为 x:{point.x},b:{point.y}");*/

    }
}
